package Leo.social.QQ;

import Leo.social.QQ.Api.OAuth2ApiBindingForQQImpl;
import Leo.social.QQ.Api.OAuth2TemplateForQQImpl;
import Leo.social.QQ.Api.QQ;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;
import org.springframework.social.oauth2.OAuth2Operations;
import org.springframework.social.oauth2.OAuth2ServiceProvider;
import org.springframework.social.oauth2.OAuth2Template;

public class OAuth2ServiceProviderForQQImpl extends AbstractOAuth2ServiceProvider<QQ> {
    String appid;
    public static final String AUTHORIZE_URL = "https://graph.qq.com/oauth2.0/authorize";
    public static final String ACCESS_TOKEN_URL = "https://graph.qq.com/oauth2.0/token";
    public OAuth2ServiceProviderForQQImpl(String appid,String clientSecret) {
        super(new OAuth2TemplateForQQImpl(appid, clientSecret, AUTHORIZE_URL, ACCESS_TOKEN_URL));
        this.appid = appid;

    }

    /**
     * Returns an API interface allowing the client application to access protected resources on behalf of a user.
     *
     * @param accessToken the API access token
     * @return a binding to the service provider's API
     */
    @Override
    public QQ getApi(String accessToken) {
        return new OAuth2ApiBindingForQQImpl(accessToken,appid);
    }
}
